-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: create gui_helpers namespace and move create font from data…
… there
- Loading branch information
Showing
4 changed files
with
31 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include "gui_helpers.h" | ||
|
||
SkFont gui_helpers::create_font_from_data(const unsigned char* font_data, size_t data_size, float font_height) { | ||
sk_sp<SkData> skData = SkData::MakeWithCopy(font_data, data_size); | ||
|
||
// Create a typeface from SkData | ||
sk_sp<SkTypeface> typeface = SkTypeface::MakeFromData(skData); | ||
|
||
if (!typeface) { | ||
printf("failed to create font\n"); | ||
return SkFont(); | ||
} | ||
|
||
return SkFont(typeface, SkIntToScalar(font_height)); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
|
||
namespace gui_helpers { | ||
SkFont create_font_from_data(const unsigned char* font_data, size_t data_size, float font_height); | ||
} |
This file contains 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