<div dir="ltr">On Tue, Mar 10, 2015 at 5:23 PM, suzuki toshiya <span dir="ltr"><<a href="mailto:mpsuzuki@hiroshima-u.ac.jp" target="_blank">mpsuzuki@hiroshima-u.ac.jp</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<span class=""><br>
Andrea Canciani wrote:<br>
> On Tue, Mar 10, 2015 at 12:17 PM, suzuki toshiya <<a href="mailto:mpsuzuki@hiroshima-u.ac.jp">mpsuzuki@hiroshima-u.ac.jp</a><br>
</span><span class="">>> I don't think the change is too complex to drop Mac OS X 10.4<br>
>> support... How do you think of?<br>
><br>
> The change itself is not very complex, but maintaining 10.4 is becoming<br>
> unfeasible, given that testing is very hard.<br>
> This is confirmed by the bug you have in your patch :P (see comment inline).<br>
<br>
</span>Oops. However, my bug seems to appear in the newest environment<br>
which lacks old API (and I don't have such environment yet X-O,<br>
so it does not show the difficulty to test 10.4 (I can do that,<br>
if somebody could give the collection of the expected results).<br></blockquote><div><br></div><div>Sorry, you're right. That typo does not show the difficulty to test 10.4 specifically, but it suggests that relying on conditional compilation and dynamic linking is more error prone. If you used the function directly, the compiler would have warned about a missing declaration and the linker about an unresolved symbol.<br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> Another option, which at least to me sounds very appealing, is to let 10.4<br>
> die (from Apple's point of view, it's unsupported since September 2009) and<br>
> cleanup cairo-quartz as in<br>
> <a href="http://cgit.freedesktop.org/~ranma42/cairo/commit/?h=wip/remove-10.4&id=66b5419704aa1971c77de764fd94b2f7d2a05b76" target="_blank">http://cgit.freedesktop.org/~ranma42/cairo/commit/?h=wip/remove-10.4&id=66b5419704aa1971c77de764fd94b2f7d2a05b76</a><br>
> This would remove most of the weirdness in the quartz backend (the two<br>
> bigger culprits are currently blend modes and font metrics).<br>
<br>
> Of course, if the remove-10.4 branch was merged, the patch to restore 10.4<br>
> would be much more complex, so we could say that supporting 10.4 requires a<br>
> significant complexity in cairo-quartz.<br>
<br>
</span>Hmm. I found that you are planning to remove runtime resolving by<br>
dlsym() completely. One of my concern is that Apple's font framework<br>
would never be stable (QuickDraw, AppleTypeService, CoreGraphics,<br>
CoreText,...). Even if cairo concentrates to CoreText font API, cairo<br>
might be asked to support new/better font framework within several<br>
years - then, the maintainer should choose again; the simplicity or<br>
multiple framework support. Is it a time to start simplicity?<br></blockquote><div><br></div><div>I do not believe that we will be able to completely get rid of it in the short term, but as you have probably noticed if we remove support for 10.4 there are only a couple of remaining dlsym-ed functions.<br><br></div><div>Ideally I would expect a new font/surface backend to be written when a new framework is released.<br></div><div>I am not sure why this was not the case for the pre-CoreText age (I was not yet working on cairo-quartz at that time), but my guess is that quite a lot of it relied on private functions, that were needed to access the features which Cairo relied upon.<br></div><div>I would be somewhat surprised if, upon the release of a new framework, font metric computation, blend modes or any currently available functions was completely removed.<br></div><div>Nonetheless I expect code to worsen when transitioning to a new framework (even if we try to keep it clean by making separate backends), but I would definitely aim for supporting a limited time span. For example, I think it would be a very bad idea to inflate cairo-quartz with support for QuickDraw. If anybody wanted it inside cairo, I would definitely suggest a separate backend (possibly with utility functions for CoreGraphics/QuickDraw interaction).<br><br></div><div>This reminds me that I started working towards a CoreText font backend...<br>I should probably take some time to figure out if it makes sense to continue working on it, as it might now be an interesting alternative to the CoreGraphics font API.<br></div><div><br></div><div>Andrea<br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Regards,<br>
mpsuzuki<br>
<div class="HOEnZb"><div class="h5"><br>
> Andrea<br>
><br>
><br>
>> Regards,<br>
>> mpsuzuki<br>
>><br>
>><br>
>> Andrea Canciani wrote:<br>
>>> From: Andrea Canciani <ranma42@tartaros.local><br>
>>><br>
>>> Since 70cc8f250b5669e757b4f044571ba0f71e3dea9e the quartz backend is<br>
>>> using some APIs that are not available on MacOSX 10.4 directly<br>
>>> (i.e. without detecting their availability through dynamic linking).<br>
>>> This means that the quartz backend does not work anymore on MacOSX<br>
>>> 10.4 and that the 10.5 SDK (or newer) is needed to build.<br>
>>> ---<br>
>>> README | 2 +-<br>
>>> 1 file changed, 1 insertion(+), 1 deletion(-)<br>
>>><br>
>>> diff --git a/README b/README<br>
>>> index 5926430..0be9947 100644<br>
>>> --- a/README<br>
>>> +++ b/README<br>
>>> @@ -121,7 +121,7 @@ Supported, "platform" surface backends<br>
>>><br>
>>> quartz backend<br>
>>> --------------<br>
>>> - MacOS X >= 10.4 with Xcode >= 2.4<br>
>>> + MacOS X >= 10.5 with Xcode >= 3.0<br>
>>><br>
>>> win32 backend<br>
>>> -------------<br>
><br>
> diff --git a/<a href="http://configure.ac" target="_blank">configure.ac</a> b/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
><br>
> index 2ce1959..23216c2 100644<br>
>> --- a/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
>> +++ b/<a href="http://configure.ac" target="_blank">configure.ac</a><br>
>> @@ -210,8 +210,43 @@ CAIRO_ENABLE_SURFACE_BACKEND(quartz, Quartz, auto, [<br>
>><br>
>> CAIRO_ENABLE_FONT_BACKEND(quartz_font, Quartz, auto, [<br>
>> use_quartz_font=$use_quartz<br>
>> + if test "x$use_quartz_font" = "xyes" ; then<br>
>> + dnl include Quartz header to check CTFontRef declaration<br>
>> + header_for_CTFontRef=""<br>
>> + if test "x${ac_cv_header_ApplicationServices_ApplicationServices_h}"<br>
>> = "xyes" ; then<br>
>> + header_for_CTFontRef=ApplicationServices/ApplicationServices.h<br>
>> + else<br>
>> + AC_CHECK_HEADER(CoreText/CoreText.h,[<br>
>> + header_for_CTFontRef=CoreText/CoreText.h<br>
>> + ],[])<br>
>> + fi<br>
>> +<br>
>> + if test "x${header_for_CTFontRef}" != "x" ; then<br>
>> + AC_CHECK_TYPE(CTFontRef,[<br>
>> + AC_DEFINE([QUARTZ_HAS_CTFONTREF_T], 1, [Define to 1 if<br>
>> CTFontRef type is defined in CTFont.h])<br>
>> + ],[],[#include "${header_for_CTFontRef}"]<br>
>> + )<br>
>> + fi<br>
>> + fi<br>
>> ])<br>
>><br>
>> +if test "x$use_quartz" = "xyes" ; then<br>
>> + dnl include Quartz header to check CGDataProviderReleaseDataCallback<br>
>> declaration<br>
>> + header_for_CGDataProviderReleaseDataCallback=""<br>
>> + if test "x${ac_cv_header_ApplicationServices_ApplicationServices_h}" =<br>
>> "xyes" ; then<br>
>> +<br>
>> header_for_CGDataProviderReleaseDataCallback=ApplicationServices/ApplicationServices.h<br>
>> + elif test "x${ac_cv_header_CoreGraphics_CoreGraphics_h}" = "xyes" ; then<br>
>> +<br>
>> header_for_CGDataProviderReleaseDataCallback=CoreGraphics/CoreGraphics.h<br>
>> + fi<br>
>> +<br>
>> + if test "x${header_for_CGDataProviderReleaseDataCallback}" != "x" ; then<br>
>> + AC_CHECK_TYPE(CGDataProviderReleaseDataCallback,[<br>
>> + AC_DEFINE([QUARTZ_HAS_CGDATAPROVIDERRELEASEDATACALLBACK_T], 1,<br>
>> [Define to 1 if CGDataProviderReleaseDataCallback type is defined in<br>
>> CGDataProvider.h])<br>
>> + ],[],[#include "${header_for_CGDataProviderReleaseDataCallback}"]<br>
>> + )<br>
>> + fi<br>
>> +fi<br>
>> +<br>
>> CAIRO_ENABLE_SURFACE_BACKEND(quartz_image, Quartz Image, no, [<br>
>> use_quartz_image=$use_quartz<br>
>> ])<br>
>> diff --git a/src/cairo-quartz-font.c b/src/cairo-quartz-font.c<br>
>> index 02f3426..35fe24d 100644<br>
>> --- a/src/cairo-quartz-font.c<br>
>> +++ b/src/cairo-quartz-font.c<br>
>> @@ -81,6 +81,18 @@ static void (*CGFontGetGlyphsForUnicharsPtr)<br>
>> (CGFontRef, const UniChar[], const<br>
>> static void (*CGContextSetAllowsFontSmoothingPtr) (CGContextRef, bool) =<br>
>> NULL;<br>
>> static bool (*CGContextGetAllowsFontSmoothingPtr) (CGContextRef) = NULL;<br>
>><br>
>> +/* Not public in the least bit */<br>
>> +static CGPathRef (*CGFontGetGlyphPathPtr) (CGFontRef fontRef,<br>
>> CGAffineTransform *textTransform, int unknown, CGGlyph glyph) = NULL;<br>
>> +<br>
>> +/* CoreText Replacement of CGFontGetGlyphPathPtr */<br>
>> +#ifdef QUARTZ_HAS_CTFONTREF_T<br>
><br>
> +static CTFontRef (*CTFontCreateWithGraphicsFontPtr) (CGFontRef , CGFloat<br>
>> size, const CGAffineTransform*, CTFontDescriptorRef) = NULL;<br>
><br>
> +static CGPathRef (*CTFontCreatePathForGlyphPtr) (CTFontRef, CGGlyph,<br>
>> CGAffineTransform *) = NULL;<br>
>> +#else<br>
>> +static void* CTFontCreateWithGraphicsFontPtr = NULL;<br>
>> +static void* CTFontCreatePathForGlyphPtr = NULL;<br>
>> +#endif<br>
>> +<br>
>> /* CGFontGetHMetrics isn't public, but the other functions are<br>
>> public/present in 10.5 */<br>
>> typedef struct {<br>
>> int ascent;<br>
>> @@ -125,6 +137,13 @@ quartz_font_ensure_symbols(void)<br>
>> CGFontGetUnitsPerEmPtr = dlsym(RTLD_DEFAULT, "CGFontGetUnitsPerEm");<br>
>> CGFontGetGlyphAdvancesPtr = dlsym(RTLD_DEFAULT,<br>
>> "CGFontGetGlyphAdvances");<br>
>><br>
>> +#ifdef QUARTZ_HAS_CTFONTREF_T<br>
>> + CTFontCreateWithGraphicsFontPtr = dlsym(RTLD_DEFAULT,<br>
>> "CTFontCreateWithGraphicsFont");<br>
>> + CTFontCreatePathForGlyphPtr = dlsym(RTLD_DEFAULT,<br>
>> "CTFontCreatePathForGlyphPtr");<br>
>><br>
><br>
> Hidden bug!<br>
> CTFontCreatePathForGlyphPtr = dlsym(RTLD_DEFAULT,<br>
> "CTFontCreatePathForGlyphPtr");<br>
> should be<br>
> CTFontCreatePathForGlyphPtr = dlsym(RTLD_DEFAULT,<br>
> "CTFontCreatePathForGlyph");<br>
><br>
><br>
>> + if (!CTFontCreateWithGraphicsFontPtr || !CTFontCreatePathForGlyphPtr)<br>
>> +#endif<br>
>> + CGFontGetGlyphPathPtr = dlsym(RTLD_DEFAULT, "CGFontGetGlyphPath");<br>
>> +<br>
>> CGFontGetHMetricsPtr = dlsym(RTLD_DEFAULT, "CGFontGetHMetrics");<br>
>> CGFontGetAscentPtr = dlsym(RTLD_DEFAULT, "CGFontGetAscent");<br>
>> CGFontGetDescentPtr = dlsym(RTLD_DEFAULT, "CGFontGetDescent");<br>
>> @@ -140,6 +159,7 @@ quartz_font_ensure_symbols(void)<br>
>> CGFontGetGlyphsForUnicharsPtr &&<br>
>> CGFontGetUnitsPerEmPtr &&<br>
>> CGFontGetGlyphAdvancesPtr &&<br>
>> + ((CTFontCreateWithGraphicsFontPtr && CTFontCreatePathForGlyphPtr)<br>
>> || CGFontGetGlyphPathPtr) &&<br>
>> (CGFontGetHMetricsPtr || (CGFontGetAscentPtr &&<br>
>> CGFontGetDescentPtr && CGFontGetLeadingPtr)))<br>
>> _cairo_quartz_font_symbols_present = TRUE;<br>
>><br>
>> @@ -545,7 +565,6 @@ _cairo_quartz_init_glyph_path<br>
>> (cairo_quartz_scaled_font_t *font,<br>
>> CGGlyph glyph = _cairo_quartz_scaled_glyph_index (scaled_glyph);<br>
>> CGAffineTransform textMatrix;<br>
>> CGPathRef glyphPath;<br>
>> - CTFontRef ctFont;<br>
>> cairo_path_fixed_t *path;<br>
>><br>
>> if (glyph == INVALID_GLYPH) {<br>
>> @@ -560,9 +579,14 @@ _cairo_quartz_init_glyph_path<br>
>> (cairo_quartz_scaled_font_t *font,<br>
>> -font->base.scale.yy,<br>
>> 0, 0);<br>
>><br>
>> - ctFont = CTFontCreateWithGraphicsFont (font_face->cgFont, 0.0, NULL,<br>
>> NULL);<br>
>> - glyphPath = CTFontCreatePathForGlyph (ctFont, glyph, &textMatrix);<br>
>> - CFRelease (ctFont);<br>
>> +#ifdef QUARTZ_HAS_CTFONTREF_T<br>
>> + if (CTFontCreateWithGraphicsFontPtr && CTFontCreatePathForGlyphPtr) {<br>
>> + CTFontRef ctFont = CTFontCreateWithGraphicsFontPtr<br>
>> (font_face->cgFont, 0.0, NULL, NULL);<br>
>> + glyphPath = CTFontCreatePathForGlyphPtr (ctFont, glyph,<br>
>> &textMatrix);<br>
>> + CFRelease (ctFont);<br>
>> + } else<br>
>> +#endif<br>
>> + glyphPath = CGFontGetGlyphPathPtr (font_face->cgFont, &textMatrix,<br>
>> 0, glyph);<br>
>> if (!glyphPath)<br>
>> return CAIRO_INT_STATUS_UNSUPPORTED;<br>
>><br>
>><br>
>><br>
><br>
<br>
</div></div></blockquote></div><br></div></div>