Last active
February 20, 2020 22:15
-
-
Save ebraminio/1e6c66de55661b0a008a463e18c5b968 to your computer and use it in GitHub Desktop.
Test CTFontCreatePathForGlyph
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// clang a.cc harfbuzz.o -std=c++11 -fno-exceptions -DHAVE_CORETEXT -framework CoreText -framework CoreFoundation -framework CoreGraphics && ./a.out | |
#include "src/hb-coretext.h" | |
static void _single_element_callback (void *info, const CGPathElement *element) | |
{ | |
switch (element->type) { | |
case kCGPathElementMoveToPoint: | |
printf ("M%lf,%lf", element->points[0].x * 100, element->points[0].x * 100); | |
break; | |
case kCGPathElementAddLineToPoint: | |
printf ("L%lf,%lf", element->points[0].x * 100, element->points[0].y * 100); | |
break; | |
case kCGPathElementAddQuadCurveToPoint: | |
printf ("Q%lf,%lf %lf,%lf", | |
element->points[0].x * 100, element->points[0].y * 100, | |
element->points[1].x * 100, element->points[1].y * 100); | |
break; | |
case kCGPathElementAddCurveToPoint: | |
printf ("Q%lf,%lf %lf,%lf %lf,%lf", | |
element->points[0].x * 100, element->points[0].y * 100, | |
element->points[1].x * 100, element->points[1].y * 100, | |
element->points[2].x * 100, element->points[2].y * 100); | |
break; | |
case kCGPathElementCloseSubpath: | |
printf ("Z"); | |
break; | |
} | |
} | |
int main() { | |
hb_blob_t *blob = hb_blob_create_from_file ("/System/Library/Fonts/NotoSansMyanmar.ttc"); | |
hb_face_t *face = hb_face_create (blob, 0); | |
hb_font_t *font = hb_font_create (face); | |
CTFontRef ref = hb_coretext_font_get_ct_font (font); | |
CGPathRef path = CTFontCreatePathForGlyph (ref, 20, nullptr); | |
CGPathApply(path, nullptr, (CGPathApplierFunction) _single_element_callback); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment