Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

I am getting countGlyphs = 0 and drawSimpleText() is not drawing any thing.

118 views
Skip to first unread message

javaid ahmad Wani

unread,
Jun 15, 2022, 10:39:52 AM6/15/22
to skia-discuss


I am using Skia c++ api  to draw test on android system  using function "
  drawSimpleText( text, strlen(text), SkTextEncoding::kUTF8, SkIntToScalar(x), SkIntToScalar(y), font, paint); "
 but it is not drawing anything on the screen, then i checked  countGlyphs   using  below code, i am getting  countGlyphs  Zero  

 ''''''''''''''


SkTypeface *typeface;
SkFont font;
typeface = font.getTypefaceOrDefault();

printf("typeface->countGlyphs = %d", typeface->countGlyphs()

'''''''''''''
On Fiddle same code is working 

Ben Wagner

unread,
Jun 15, 2022, 12:49:41 PM6/15/22
to skia-d...@googlegroups.com
This implies that font.getTypefaceOrDefault(); is returning the
fallback empty SkTypeface (which has no glyphs and draws nothing).
Your build of Skia needs to contain some means of creating SkTypefaces
from data (generally by building the proper SkFontMgr implementations
and using them). In general SkFont::getTypefaceOrDefault and
SkCanvas::drawSimpleText are both "toy" APIs. They are interesting to
get something working quickly, but should not be used in any serious
application. It is best to avoid use of a default SkFontMgr and
drawSimpleText does no text shaping (only works as expected with
simple fonts without any shaping information and does no font
fallback).
> --
> You received this message because you are subscribed to the Google Groups "skia-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/ec3dcd94-b613-46c8-b99a-3669770a6544n%40googlegroups.com.
Message has been deleted

zhenghong zhang

unread,
May 21, 2024, 8:19:32 AM5/21/24
to skia-discuss
Dear bungeman,
   You said that ' In general SkFont::getTypefaceOrDefault and SkCanvas::drawSimpleText are both "toy" APIs.', i got three questions for this:
   1) Why you said that drawSimpleText is a toy api while doc SKCanvas.h doesn't mean that explicitly, Is there some explanations i haven't find
   2) Is drawSimpleText still a toy api in chrome/m121 version?
   3) Is there any other api which can implement functions of drawSimpleText? Or any other recommended equivalent api
Looking forward your replies!!!

zhenghong zhang

unread,
May 21, 2024, 8:19:47 AM5/21/24
to skia-discuss
Dear Ben Wagner,
     You said that ‘In general SkFont::getTypefaceOrDefault and SkCanvas::drawSimpleText are both "toy" APIs.’, i got three questions for that:
     1) Why you say that drawSimpleText is a toy api in skia while the doc file SKCanvas.h haven't mean for that explicitly. Is there any explanations i haven't found?
     2) Is drawSimpleText still a "toy" api in chrome/m121 version?
     3) If drawSimpleText doesn't work, which API should i need to use?
Looking forward your replies!
Reply all
Reply to author
Forward
0 new messages