Commit Graph

71 Commits

Author SHA1 Message Date
Greg Ercolano
da737bb10b Avoid freeing NULL.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9999 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2013-10-20 20:17:13 +00:00
Manolo Gouy
32d4bc4099 Fix STR#2810: removed all uses of function Fl_Device::class_name().
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9293 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2012-03-18 18:48:29 +00:00
Greg Ercolano
4f4a8fc3c7 Modifications to all LGPL headers for STR #2685.
(to clarify static exception LGPL by changing license references)



git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8864 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2011-07-19 04:49:30 +00:00
Ian MacArthur
41fc90726b Hopefully this fixes the bug Albrecht found in using fl_measure on surrogate pairs whilst we were looking at STR #2622.
In summary, if you measured the string *before* the selected font had been used to actually fl_draw() anything, the measurement returned was invalid, as the new font was not "locked in" to the gc.
This change makes sure the selected font is set in the gc before making the measurement.
In tests, this appears to work correctly now...
More opinions welcomed!


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8644 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2011-05-10 15:37:05 +00:00
Ian MacArthur
eb16787f7a Pushing this as a possible fix for STR #2622.
This might not be correct (though I think it is) but should be no worse than the current mess I made...

Please test with as many different win32/64 compilers as possible and let me know!




git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8643 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2011-05-10 09:27:18 +00:00
Ian MacArthur
451b91ea46 OK - this time I actually think I have got it.
The win32 text-extents stuff now seems to be handling surrogate pairs correctly,
at least in my testing harness, and with a variety of supplementary plane fonts.

I really will leave this alone now - unless anyone finds bugs of course!

I have tested for regressions and it seems to be fine AFAICT.



git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8605 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2011-04-18 14:34:20 +00:00
Ian MacArthur
ac5d865986 This WIN32 patch introduces a credible (though far from ideal)
workaround for text_extents being measured on glyphs from
supplementary Unicode planes.
It has no effect on glyphs from the Basic plane, so should not
be visible at all to most code.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8600 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2011-04-17 21:19:14 +00:00
Ian MacArthur
be6df55717 More attempts to clean up WIN32 handling of UTF16 surrogate pairs.
In particular, I have added a new function to src/fl_utf.c called fl_ucs_to_Utf16() which
converts a single 32-bit Unicode value into one (or more) UTF16 cells.

This is needed in the win32 char-by-char text width() logic, and I suspect may also be useful in the OSX code in some places.



git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8585 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2011-04-13 15:43:22 +00:00
Ian MacArthur
1d988db2db Under win32, text_extents() is not handling surrogate pairs either, at least on XP.
The problem seems to be in GetGlyphIndicesW() which is returning invalid indices for the surrogate pairs.
This causes subsequent measurements of the glyphs to fail, of course.

This patch does not fix the problem, it only makes sure it fails cleanly, causing a fallback to the default fl_measure like behaviour.
This is not nice, nor what I want, but at least it is consistent for now...



git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8582 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2011-04-12 16:18:42 +00:00
Ian MacArthur
38a3c21ffd Modify win32 text width(ucs) function to handle surrogate pairs.
This now correctly measures glyphs whose codepoint requires a surrogate pair to represent it in UTF16.

NOTE 1: This code makes any UCS point > 0xFFFF a "special case" and measures it explicitly, rather than using the lookup table. This "explicit measure" may be slow, but actually seems OK in my tests, so far.
The lookup table still covers the basic multilingual plane and is used for any glyph <= 0xFFFF as before, so the behaviour for most existing bodies of text is unchanged.

This code also retains the historical behaviour under Win32 whereby strings are measured char-by-char rather than as a whole string - again this is intended to retain compatability with existing implementations.

It is proposed that we should move towards measuring entire strings in the future as this is conceivably more efficient and certainly more consistent - rendering is now largely done "string as a whole" so we ought to measure in that way too; though to date the differences seem tiny, as evdienced by the text rendering page of the unittest example.

NOTE 2: This does not fix the *rendering* of surrogate pairs under XP, which still seems to be broken. I suspect that TextOutW() may genuinely broken under XP, as it works fine on Vista, and it is not just my code that seems broken, other non-fltk programs exhibit the same aberrant behaviour. Measuring of surrogate pairs appears to work correctly though...
Maybe we are using TextOutW() wrongly?




git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8580 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2011-04-12 10:08:58 +00:00
Ian MacArthur
d065ca89fe modify the win32 text ::draw() function to do "string at once" rather than "char by char" rendering, as advised by Bill and Manolo.
This seems to be good so far, though does not resolve the XP surrogate pairs issues.
If this fix is bad, we need to revert to r8577, which is good...

And I still haven't fixed the handling of width in win32 code, so it is still inconsistent with draw for high Ubicode points.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8579 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2011-04-11 22:00:19 +00:00
Ian MacArthur
924ed100d6 Minor rework of code to make ::rtl_draw() and ::draw(int angle,...) more consistent in coding terms. Behaviour of output unchanged.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8578 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2011-04-11 21:49:05 +00:00
Ian MacArthur
4710a67670 Remove use of the MS API call MultiByteToWideChar(...) and re-instate use of fl_utf8toUtf16(...) now that I have fixed a slight off-by-one in handling the ends of the input strings.
This makes string handling much more consistent across variants.
Doh!. I am such an idiot...

NOTE: This still does not fix aberrant handling of surrogate pairs under WinXP, and I still haven't resolved the issues with the win32 ::width() functions not handling surrogate pairs at all...




git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8575 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2011-04-11 13:13:08 +00:00
Ian MacArthur
016219f4a2 Replace a few instances of fl_utf8toUtf16() with the near-equivalent MS API call MultiByteToWideChar() as this seems to fix the regression I introduced in the rendering of rotated text on WinXP.
However... It does not cause the "high" Unicode code points to render correctly on XP, even though they do work on Vista (and I assume later variants like Win7...)
So there's still something I am missing here. Maybe XP is just broken? That'll be a problem...



git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8570 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2011-04-07 09:28:45 +00:00
Ian MacArthur
8a830853bc Further work to fix win32 handling of surrogate pairs for "high" Unicode points... Now fixed handling of rotated text version of win32 draw method.
Fixes to the various ::width() methods for win32 and OSX still TBD.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8568 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2011-04-06 21:37:13 +00:00
Ian MacArthur
f7e251e69b Initial work to fix handling of surrogate pairs on win32 - draw() was not handling any Unicode char above U+FFFF as we did not handle the case where more than one UTF16 cell was required to hold the full glyph.
This change works, but is incomplete, other sections of the win32 code (and possibly OSX code) are making the same invalid assumptions about UTF16 chars.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8567 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2011-04-06 21:02:35 +00:00
Manolo Gouy
199b32d921 Added virtual width(), height(), descent() and text_extents() functions to the Fl_Graphics_Driver
class to prepare for the future definition of graphics drivers that fully deal with text measurement.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8442 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2011-02-18 13:39:48 +00:00
Manolo Gouy
162895ad57 Improved calculation of text width and height when using the PostScript graphics context
under Mac OS and MSWindows.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8438 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2011-02-16 15:17:01 +00:00
Manolo Gouy
cb902eebe3 Replaced global variable fl_fontsize by fl_graphics_driver->font_descriptor().
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8395 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2011-02-07 13:49:34 +00:00
Manolo Gouy
777ee1b822 Removed global variables fl_font_ and fl_size_ that are now distinct for each graphics device.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8374 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2011-02-05 13:54:56 +00:00
Manolo Gouy
2251609ab3 Fix STR #2553: in function fl_width(unsigned), the SelectObject() statement was
put before making sure we have a valid gc, which was wrong.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8365 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2011-02-03 23:00:30 +00:00
Manolo Gouy
63e77dfe56 Removed compilation warning in fl_font_win32.cxx
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8213 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2011-01-07 16:19:30 +00:00
Manolo Gouy
4beb3b88e8 Renamed Fl_Device::type() to Fl_Device::class_name() to avoid conflict or confusion
with Fl_Widget::type(). Added a setter function Fl_Device::class_name(const char *).

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8190 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2011-01-05 10:21:45 +00:00
Manolo Gouy
d3d16a354e Win32 right-to-left text: output whole string to obtain correct ligatures between Arabic letters.
This new algorithm is not coherent with fl_width() but allows minimal usage of fl_rtl_draw().
The utf8 demo shows the effect of this change.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8134 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2010-12-28 21:24:15 +00:00
Manolo Gouy
b431c1e0e7 Use device abstraction for font and text drawing.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8126 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2010-12-28 12:02:23 +00:00
Albrecht Schlosser
f90c190a8e Fixed some compiler warnings, most of them in Windows-specific code.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7975 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2010-12-08 12:15:48 +00:00
Greg Ercolano
4327734e69 More copyright 2010 mods.
Used: vi `grep -r 'Copyright .*Spitzak' . | grep -v 2010 | grep -v '/\.svn' | cut -d: -f1`


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7913 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2010-11-29 18:18:27 +00:00
Manolo Gouy
449b99dd86 Fix STR 2339 by defining new member function rtl_draw of class Fl_Graphics_Driver
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7652 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2010-06-21 15:49:45 +00:00
Manolo Gouy
26049351e0 Better device hierarchy with surfaces and graphics drivers.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7617 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2010-05-27 17:20:18 +00:00
Manolo Gouy
d0b1cc30f7 Removed multiple inheritance: back to r. 7519 exactly.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7522 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2010-04-18 06:57:37 +00:00
Manolo Gouy
913530758a Improved the hierarchy of Fl_Device subclasses to allow separation of platform-specific devices.
This introduces multiple inheritance.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7520 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2010-04-16 20:19:09 +00:00
Albrecht Schlosser
998cc6df52 Merge of branch-1.3-Fl_Printer, with the following main changes:
(1) adding Fl_Device class (and more) for device abstraction
 (2) adding Fl_Pinter class (and more) for printing support.

Todo: Code cleanup, update dependencies, remove/replace test print window.
I'm looking into converting the test window popup in a global shortcut
that would pop up the print dialog now...


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7263 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2010-03-14 18:07:24 +00:00
yuri
f13defde28 add fl_draw(int angle, const char* ... functions for rotated text drawing
STR#1840 closed, STR#207 not closed because non-xft functions not implemented 

drawing of N Utf8 characters need correction for rotated and not rotated fl_draw functions not solved!


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6779 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2009-04-24 09:28:30 +00:00
Ian MacArthur
24f313298f Copy into fl_text_extents() Fabien's defensive code for obtaining an fl_gc (in case we do not have a valid one) copied from the win32 implementation of fl_width.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6661 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2009-02-15 21:52:49 +00:00
Matthias Melcher
5251b64d57 Changed Copyright in 'src' directory
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6616 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2009-01-01 21:28:26 +00:00
Fabien Costantini
7b49e892b8 Fixing corelib would not compile under vc6 following fl_text_extents() addons. checked on win32/vc6,macosx. Please on other win32 compilers.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6578 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2008-12-11 14:38:04 +00:00
Fabien Costantini
5182f58f01 STR#2086: one line was missing from latest fix, so hWnd was always null, sorry.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6541 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2008-12-04 17:45:50 +00:00
Fabien Costantini
899184656a STR#2086 related Fixes :
This one was really tough to track, understand:
In fact, 
the problem was comming from the misplacement of the menu window,
which itself came from invalid measurement,
which itself came from invalid fl_witdh() measurement,
but only when fl_gc is not valid because fl_width() relies on Win32 on the call
of GetTextExtentPoint32W which can't succeed if the HDC(here fl_gc) is not valid !

Now the fix:
A best-effort algorithm has been furthered to supply a valid fltk hdc if we can have one or a screen hdc if no fltk window is found by fl::first_window().

Note that when fl_gc is NULL inside fl_width() call, it can happen that Fl_Window::current() is not null but invalid (already deleted).
Finally, in the case of the buggy menu window observed here, this  fl_gc was set to NULL just after an Fl_Menu_Window deletion and re-creation in Fl_Menu_Item::pulldown().

Also added a comment to describe the new fl_width() behavior.



git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6540 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2008-12-04 17:33:30 +00:00
Albrecht Schlosser
0f13d6eff2 Applying a correction requested by Ian:
"The problem is line 237, the "unsigned len" declaration is potentially
crossed by the preceeding goto (line 234) so some compilers don't like
that..."

Tested okay on cygwin with gcc 3.4.4.


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6535 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2008-12-02 11:10:03 +00:00
Ian MacArthur
8d4bff7545 STR #2076 redux: Make the Win32 variant only load GetGlyphIndicesW at runtime, so that the fl_text_extents code will still work on WinNT and other early systems.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6534 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2008-12-01 21:01:58 +00:00
Ian MacArthur
865f3d8e61 STR 2076: experimental fl_text_extents patch applied. Please feedback comments.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6529 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2008-11-19 20:34:27 +00:00
Fabien Costantini
e8478458bf Doxygen documentation: Fixed most important warnings for the Fl_Widget, Fl_Window, Fl_Valuator classes that should be now a 100% documented. For the rest I drastically reduced the undocumented APIs, but many others (less important) remains.
It looks and feels pretty good now :-)


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6299 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2008-09-18 19:09:34 +00:00
Matthias Melcher
b6bde2e456 Merging the UTF8 patch, consisting of O'ksi'd s original 1.1.6 patch and additions by Ian. PLEASE BE AWARE that the patch in its current incarnation is a regression in many aspects and further work is required before we can announce Unicode support.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6212 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2008-09-10 23:56:49 +00:00
Matthias Melcher
b6b746cd69 Replaced badly named type Fl_FontSize with Fl_Font_Descriptor. This type is only used in the core files and not available to the user.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6162 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2008-08-15 21:18:27 +00:00
Matthias Melcher
e63c50b2d1 Rename type Fl_Font_Size into Fl_Fontsize to comply with other naming in FLTK.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6161 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2008-08-15 21:11:21 +00:00
Matthias Melcher
7c8f5cc888 First attempt at consistently using Fl_Font as a type for the font index and Fl_Font_Size as a type to measure font height (or rather size).
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6113 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2008-04-23 19:09:28 +00:00
Matthias Melcher
caa6fd1ff2 Fixed font caching issue from STR 1415
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5420 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2006-09-05 11:16:15 +00:00
Michael R Sweet
2d35bc7a2a fl_draw() would segfault on WIN32 if no font was set; it now uses
the default font (STR #828)



git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4329 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2005-05-12 13:37:49 +00:00
Michael R Sweet
1c399af444 Update source file headers with STR web page.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4288 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2005-04-16 00:13:17 +00:00
Michael R Sweet
add37faa25 Copyright updates.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4052 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
2005-02-24 21:55:12 +00:00