Skip to content

Commit

Permalink
Loading the ttf files which are common on Desktop and Phone.
Browse files Browse the repository at this point in the history
This fixes the issue where no text was shown on Phone in WOCCatalog.
  • Loading branch information
amagams committed Jun 24, 2016
1 parent 62c3993 commit b73a70c
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions samples/WOCCatalog/WOCCatalog/TextDisplayViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,7 @@ - (id)init {
addObject:[self makeTestCellWithTitle:title
WithAccessoryUIView:[self makeTextDrawer:13 WithCustomHeight:130 WithCustomBackgroundColor:[UIColor grayColor]]]];

title =
@"CTFontManagerRegisterFontsForURL: (Register different fonts familys)\nfont 1: Harlow Solid Italic\nfont 2: Goudy Stout\nfont 3: "
@"Kunstler Script";
title = @"CTFontManagerRegisterFontsForURL: (Register different fonts familys)\nfont 1: Times New Roman\nfont 2: Gadugi";
[rows addObject:[self makeTestCellWithTitle:title WithAccessoryUIView:[self makeTextDrawer:14]]];

return self;
Expand Down Expand Up @@ -313,7 +311,7 @@ - (UITextView*)basicUITextView2 {

uiTextView.text = TestParagraph;

//intentionally setting text color after setting text
// intentionally setting text color after setting text
uiTextView.textColor = [UIColor blueColor];

uiTextView.returnKeyType = UIReturnKeyDefault;
Expand Down Expand Up @@ -487,38 +485,28 @@ - (void)testCTFontManagerRegisterFontsForURL:(CGRect)rect {
CGContextScaleCTM(context, 1.0, -1.0);

// font 1
NSURL* url = [NSURL fileURLWithPath:@"C:/Windows/Fonts/KUNSTLER.TTF"];
NSURL* url = [NSURL fileURLWithPath:@"C:/Windows/Fonts/gadugi.ttf"];
bool result = CTFontManagerRegisterFontsForURL((__bridge CFURLRef)(url), kCTFontManagerScopeProcess, NULL);
if (result) {
UIFont* font = [UIFont fontWithName:@"Kunstler Script" size:22.0];
UIFont* font = [UIFont fontWithName:@"Gadugi" size:22.0];
CTTypesetterRef typesetter =
CTTypesetterCreateWithAttributedString((__bridge CFAttributedStringRef)[self getAttributedStringForFont:font]);
CFRange range = { 0, 11 };
CTLineRef line = CTTypesetterCreateLineWithOffset(typesetter, range, 0.0f);
CTLineDraw(line, context);
}

// font 2
url = [NSURL fileURLWithPath:@"C:/Windows/Fonts/GOUDYSTO.TTF"];
url = [NSURL fileURLWithPath:@"C:/Windows/Fonts/times.ttf"];
result = CTFontManagerRegisterFontsForURL((__bridge CFURLRef)(url), kCTFontManagerScopeProcess, NULL);
if (result) {
UIFont* font = [UIFont fontWithName:@"Goudy Stout" size:22.0];
UIFont* font = [UIFont fontWithName:@"Times New Roman" size:22.0];
CTTypesetterRef typesetter =
CTTypesetterCreateWithAttributedString((__bridge CFAttributedStringRef)[self getAttributedStringForFont:font]);
CFRange range = { 0, 11 };
CTLineRef line = CTTypesetterCreateLineWithOffset(typesetter, range, 0.0f);
CGContextSetTextPosition(context, 0.0, 25.0);
CTLineDraw(line, context);
}
// font 3
url = [NSURL fileURLWithPath:@"C:/Windows/Fonts/HARLOWSI.TTF"];
result = CTFontManagerRegisterFontsForURL((__bridge CFURLRef)(url), kCTFontManagerScopeProcess, NULL);
if (result) {
UIFont* font = [UIFont fontWithName:@"Harlow Solid Italic" size:22.0];
CTTypesetterRef typesetter =
CTTypesetterCreateWithAttributedString((__bridge CFAttributedStringRef)[self getAttributedStringForFont:font]);
CFRange range = { 0, 11 };
CTLineRef line = CTTypesetterCreateLineWithOffset(typesetter, range, 0.0f);
CGContextSetTextPosition(context, 0.0, 50.0);

CTLineDraw(line, context);
}
}
Expand Down

0 comments on commit b73a70c

Please sign in to comment.