Hello, in commonMain I’ve the following expect: ``...
# compose-ios
g
Hello, in commonMain I’ve the following expect:
Copy code
@Composable
expect fun PlatformFont(name: String, weight: FontWeight, style: FontStyle): Font
Then in androidMain:
Copy code
@Composable
actual fun PlatformFont(name: String, weight: FontWeight, style: FontStyle): Font {
    return with(LocalContext.current) {
        Font(resources.getIdentifier(name, "font", packageName), weight, style)
    }
}
jvm:
Copy code
@Composable
actual fun PlatformFont(name: String, weight: FontWeight, style: FontStyle): Font =
    androidx.compose.ui.text.platform.Font("font/${name}.ttf", weight, style)
Can anyone help me with iosMain actual? 🙏 Thanks!
👍 1
g
I don’t know if this is related but I’m seeings this logs:
Copy code
Tassk :linkPodDebugFrameworkIosSimulatorArm64 FAILED
Copy code
Undefined symbols for architecture arm64:
  "_CTFontCollectionCreateFromAvailableFonts", referenced from:
      SkFontMgr_Mac::SkFontMgr_Mac(__CTFontCollection const*) in libskia.a(fontmgr_mac_ct.SkFontMgr_mac_ct.o)
  "_CTFontCollectionCreateMatchingFontDescriptors", referenced from:
      (anonymous namespace)::SkCopyAvailableFontFamilyNames(__CTFontCollection const*) in libskia.a(fontmgr_mac_ct.SkFontMgr_mac_ct.o)
  "_CTFontCopyAttribute", referenced from:
      SkCTFontCreateExactCopy(__CTFont const*, double, OpszVariation) in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
      SkTypeface_Mac::onOpenStream(int*) const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
  "_CTFontCopyAvailableTables", referenced from:
      SkTypeface_Mac::onGetTableTags(unsigned int*) const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
  "_CTFontCopyCharacterSet", referenced from:
      SkTypeface_Mac::getGlyphToUnicodeMap(int*) const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
  "_CTFontCopyFamilyName", referenced from:
      SkTypeface_Mac::onGetFamilyName(SkString*) const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
      SkTypeface_Mac::onGetFontDescriptor(SkFontDescriptor*, bool*) const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
  "_CTFontCopyFontDescriptor", referenced from:
      SkTypeface_Mac::Make(std::__1::unique_ptr<__CTFont const, SkOverloadedFunctionObject<void (void const*), &CFRelease>>, OpszVariation, std::__1::unique_ptr<SkStreamAsset, std::__1::default_delete<SkStreamAsset>>)::$_0::operator()() const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
      SkCTFontGetDataFontWeightMapping() in libskia.a(libskia.SkCTFont.o)
  "_CTFontCopyFullName", referenced from:
      SkTypeface_Mac::onGetFontDescriptor(SkFontDescriptor*, bool*) const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
  "_CTFontCopyGraphicsFont", referenced from:
      SkTypeface_Mac::onGetUPEM() const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
      SkTypeface_Mac::onGetTableData(unsigned int, unsigned long, unsigned long, void*) const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
      SkTypeface_Mac::onCopyTableData(unsigned int) const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
      SkScalerContext_Mac::SkScalerContext_Mac(sk_sp<SkTypeface_Mac>, SkScalerContextEffects const&, SkDescriptor const*) in libskia.a(fontmgr_mac_ct.SkScalerContext_mac_ct.o)
  "_CTFontCopyLocalizedName", referenced from:
      SkTypeface_Mac::onCreateFamilyNameIterator() const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
  "_CTFontCopyPostScriptName", referenced from:
      SkTypeface_Mac::onGetAdvancedMetrics() const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
      SkTypeface_Mac::onGetPostScriptName(SkString*) const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
      SkTypeface_Mac::onGetFontDescriptor(SkFontDescriptor*, bool*) const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
  "_CTFontCopyTable", referenced from:
      SkTypeface_Mac::onGetTableData(unsigned int, unsigned long, unsigned long, void*) const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
      SkTypeface_Mac::onCopyTableData(unsigned int) const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
  "_CTFontCopyVariation", referenced from:
      SkTypeface_Mac::onGetVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate*, int) const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
      SkCTVariationFromSkFontArguments(__CTFont const*, __CFArray const*, SkFontArguments const&) in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
  "_CTFontCopyVariationAxes", referenced from:
      SkFontMgr_Mac::onMakeFromStreamArgs(std::__1::unique_ptr<SkStreamAsset, std::__1::default_delete<SkStreamAsset>>, SkFontArguments const&) const in libskia.a(fontmgr_mac_ct.SkFontMgr_mac_ct.o)
      SkTypeface_Mac::onGetAdvancedMetrics() const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
      SkTypeface_Mac::getVariationAxes() const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
      SkTypeface_Mac::onGetVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate*, int) const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
      SkTypeface_Mac::onMakeClone(SkFontArguments const&) const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
      SkTypeface_Mac::onGetVariationDesignParameters(SkFontParameters::Variation::Axis*, int) const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
  "_CTFontCreateCopyWithAttributes", referenced from:
      SkFontMgr_Mac::onMakeFromStreamArgs(std::__1::unique_ptr<SkStreamAsset, std::__1::default_delete<SkStreamAsset>>, SkFontArguments const&) const in libskia.a(fontmgr_mac_ct.SkFontMgr_mac_ct.o)
      SkCTFontCreateExactCopy(__CTFont const*, double, OpszVariation) in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
      SkTypeface_Mac::onMakeClone(SkFontArguments const&) const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
  "_CTFontCreateCopyWithSymbolicTraits", referenced from:
      create_from_name(char const*, SkFontStyle const&) in libskia.a(fontmgr_mac_ct.SkFontMgr_mac_ct.o)
  "_CTFontCreateForString", referenced from:
      SkFontMgr_Mac::onMatchFamilyStyleCharacter(char const*, SkFontStyle const&, char const**, int, int) const in libskia.a(fontmgr_mac_ct.SkFontMgr_mac_ct.o)
  "_CTFontCreatePathForGlyph", referenced from:
      SkScalerContext_Mac::generateMetrics(SkGlyph*, SkArenaAlloc*) in libskia.a(fontmgr_mac_ct.SkScalerContext_mac_ct.o)
      SkScalerContext_Mac::generatePath(SkGlyph const&, SkPath*) in libskia.a(fontmgr_mac_ct.SkScalerContext_mac_ct.o)
  "_CTFontCreateWithFontDescriptor", referenced from:
      SkFontMgr_Mac::onMatchFamilyStyle(char const*, SkFontStyle const&) const in libskia.a(fontmgr_mac_ct.SkFontMgr_mac_ct.o)
      SkFontMgr_Mac::onMatchFamilyStyleCharacter(char const*, SkFontStyle const&, char const**, int, int) const in libskia.a(fontmgr_mac_ct.SkFontMgr_mac_ct.o)
      (anonymous namespace)::SkFontStyleSet_Mac::createTypeface(int) in libskia.a(fontmgr_mac_ct.SkFontMgr_mac_ct.o)
      (anonymous namespace)::SkFontStyleSet_Mac::matchStyle(SkFontStyle const&) in libskia.a(fontmgr_mac_ct.SkFontMgr_mac_ct.o)
      (anonymous namespace)::ctfont_from_skdata(sk_sp<SkData>, int) in libskia.a(fontmgr_mac_ct.SkFontMgr_mac_ct.o)
      create_from_name(char const*, SkFontStyle const&) in libskia.a(fontmgr_mac_ct.SkFontMgr_mac_ct.o)
      SkCTFontGetSmoothBehavior() in libskia.a(libskia.SkCTFont.o)
      ...
  "_CTFontDescriptorCopyAttribute", referenced from:
      (anonymous namespace)::SkCopyAvailableFontFamilyNames(__CTFontCollection const*)::$_2::__invoke(void const*, void*) in libskia.a(fontmgr_mac_ct.SkFontMgr_mac_ct.o)
      (anonymous namespace)::SkFontStyleSet_Mac::getStyle(int, SkFontStyle*, SkString*) in libskia.a(fontmgr_mac_ct.SkFontMgr_mac_ct.o)
      SkCTFontDescriptorGetSkFontStyle(__CTFontDescriptor const*, bool) in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
      SkCTFontGetDataFontWeightMapping() in libskia.a(libskia.SkCTFont.o)
  "_CTFontDescriptorCreateMatchingFontDescriptors", referenced from:
      SkFontMgr_Mac::CreateSet(__CFString const*) in libskia.a(fontmgr_mac_ct.SkFontMgr_mac_ct.o)
  "_CTFontDescriptorCreateWithAttributes", referenced from:
      SkFontMgr_Mac::onMakeFromStreamArgs(std::__1::unique_ptr<SkStreamAsset, std::__1::default_delete<SkStreamAsset>>, SkFontArguments const&) const in libskia.a(fontmgr_mac_ct.SkFontMgr_mac_ct.o)
      SkFontMgr_Mac::CreateSet(__CFString const*) in libskia.a(fontmgr_mac_ct.SkFontMgr_mac_ct.o)
      create_descriptor(char const*, SkFontStyle const&) in libskia.a(fontmgr_mac_ct.SkFontMgr_mac_ct.o)
      SkCTFontCreateExactCopy(__CTFont const*, double, OpszVariation) in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
      SkTypeface_Mac::onMakeClone(SkFontArguments const&) const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
  "_CTFontDrawGlyphs", referenced from:
      SkCTFontGetSmoothBehavior() in libskia.a(libskia.SkCTFont.o)
      SkScalerContext_Mac::Offscreen::getCG(SkScalerContext_Mac const&, SkGlyph const&, unsigned short, unsigned long*, bool) in libskia.a(fontmgr_mac_ct.SkScalerContext_mac_ct.o)
  "_CTFontGetAdvancesForGlyphs", referenced from:
      SkScalerContext_Mac::generateMetrics(SkGlyph*, SkArenaAlloc*) in libskia.a(fontmgr_mac_ct.SkScalerContext_mac_ct.o)
  "_CTFontGetAscent", referenced from:
      SkTypeface_Mac::onGetAdvancedMetrics() const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
      SkScalerContext_Mac::generateFontMetrics(SkFontMetrics*) in libskia.a(fontmgr_mac_ct.SkScalerContext_mac_ct.o)
  "_CTFontGetBoundingBox", referenced from:
      SkTypeface_Mac::onGetAdvancedMetrics() const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
      SkScalerContext_Mac::generateFontMetrics(SkFontMetrics*) in libskia.a(fontmgr_mac_ct.SkScalerContext_mac_ct.o)
  "_CTFontGetBoundingRectsForGlyphs", referenced from:
      SkTypeface_Mac::onGetAdvancedMetrics() const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
      SkScalerContext_Mac::generateMetrics(SkGlyph*, SkArenaAlloc*) in libskia.a(fontmgr_mac_ct.SkScalerContext_mac_ct.o)
  "_CTFontGetCapHeight", referenced from:
      SkTypeface_Mac::onGetAdvancedMetrics() const in libskia.a(fontmgr_mac_ct.SkTypeface_mac_ct.o)
....
ld: symbol(s) not found for architecture arm64
error: Compilation finished with errors

FAILURE: Build failed with an exception.
🤔
I had to make
framework.isStatic = true
to solve it
Now, I’m having a runtime error:
Uncaught Kotlin exception: kotlin.IllegalStateException: File <name>.ttf not found in Bundle
I’ll double check the tivi sample to see what have I missed
for future reference:
Copy code
struct Fonts {
  static let Led = "LedPanelStationOn" //turns out that using printFontNames() insinde .onAppear() reveals the real name...
   
  static func printFontNames() {
    for family: String in UIFont.familyNames {
      print(family)
      for names: String in UIFont.fontNames(forFamilyName: family) {
        print("== \(names)")
      }
    }
  }
}
I was using Led.tff but for iOS “Led” does not exists. So with this code I found out the “real name” Changed the files and it works 🙂