[cairo] utf8 text rendering on iOS

Behdad Esfahbod behdad at behdad.org
Mon Feb 27 16:01:27 PST 2012


On 02/25/2012 02:15 PM, cu wrote:
> Thank you for the stock answer.
> 
> We've been using the "toy" API on a number of platforms, including
> MacOS. It works well enough and shows utf8 fonts correctly.  I am
> interested in making sure it works just as correctly on iOS as it does
> on other platforms. Any useful advice would be appreciated.


What you see means one of two things:

- The font you are choosing doesn't have glyphs for the characters you are
trying to render,

- You are encoding your text wrongly (less likely).

You should check what font backends are actually being enabled / used.  If no
native font backends could be enabled, then all you get is the internal cairo
font which only supports ASCII.

If you want automatic font substitution, and non-Latin support or advanced
typographic features, what Dom said shall be take more seriously (as opposed
to take as a 'stock answer').  Either use PangoCairo, or build a text
rendering system yourself using HarfBuzz, Cairo, FriBidi, and other pieces
(much much more work).

Two cents from your resident text rendering expert.  Feel free to ignore.
behdad


> Dominic Lachowicz wrote:
>> The cairo_show_text() function call is part of what the cairo
>> designers call the "toy" text API. It is convenient for short demos
>> and simple programs, but it is not expected to be adequate for serious
>> text-using applications.
>>
>> On Sat, Feb 25, 2012 at 1:55 PM, cu <cairouser at yahoo.com> wrote:
>>   
>>> Dear all,
>>>
>>>  I seem to have an issue rendering utf8 text using Cairo + freetype
>>> backend on iOS/iPhone. Fonts are loaded correctly and ASCII text renders
>>> correctly using appropriate font. Any utf8 glyphs are replaced by empty
>>> square. Does anyone have an insight into this issue? Where do I even
>>> begin digging?
>>> --
>>> cairo mailing list
>>> cairo at cairographics.org
>>> http://lists.cairographics.org/mailman/listinfo/cairo
>>>     
>>
>>
>>
>>   
> 
> --
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
> 


More information about the cairo mailing list