https://helpx.adobe.com/fonts/using/add-fonts-website.html#Createawebpro...

Typekit is now Adobe Fonts

We used to organize web fonts for a particular site into a kit; now we call that a web project.

The fonts are still added to your website with the embed code that we provide

There is nowhere to enter a domain as was done previously with Typekit. I pestered Adobe and they said:

The new approach has no domain restrictions!

But when I set up a new 'project' I cannot seem to connect it to the site using the module (my typekit credentials are in, as usual). All the old sites/kits work fine.

Adobe wants me to insert code into like this:
<link rel="stylesheet" href="https://use.typekit.net/tfg6xoz.css">

is there a way to use the module as it exists? or will this require adjustment?

thanks!!!

Comments

stellarvisions created an issue. See original summary.

stellarvisions’s picture

Not relevant to the primary issue, just trying a temporary workaround.

I tried calling on the external stylesheet from template.php as noted below.
https://www.drupal.org/docs/7/theming/working-with-css/adding-style-shee...

function mytheme_preprocess_html(&$variables) {
  drupal_add_css('https://use.typekit.net/tfg6xoz.css', array('type' => 'external'));
}

Cleared caches, and put font in stylesheet, and it's being called upon in the HTML, but font not appearing.

droprocker’s picture

Is there a need for a/this module anyway in case of Adobe Fonts?

You can just copy the code

<link rel="stylesheet" href="https://use.typekit.net/tfg6xoz.css">

and paste it in your head-section in html.html.twig and add your fonts in your CSS file. Its fast, its simple and theres no need to blow up drupal code with an module not serving any extra benefit for this task.

I kinda love the new approach of Adobe fonts, cause everyone can implement fonts easily with just ONE line of extra code. So just uninstall font-your-face and enjoy. ;-)

By the way, this is also an 8.x issue.

stellarvisions’s picture

Thanks, this is what we will do going forward. For Drupal 7 would it be the html.tpl.php.

We will have some challenges because we have customers who share themes . . . but we'll figure it out.

thanks again.

stellarvisions’s picture

I see that the project ID becomes the URL, we could make at project ID variable and then call on it in the head

i will look around in documentation, but if anyone has done this, guidance appreciated

mikedance’s picture

I have run into this issue, new font imports are failing because its still attempting to match against a domain (that is no longer present from the api)

mikedance’s picture

StatusFileSize
new2.75 KB

Here is a patch to fix the problem

junaidpv’s picture

Status: Active » Needs review
StatusFileSize
new2.92 KB

Patch from #7 does not apply. Here is re-rolled one, also have minor improve handle it better when variant not found at Typekit.

junaidpv’s picture

StatusFileSize
new3.42 KB
new2.77 KB

Previous patch Improved to

  • show better message when font family not found.
  • remove existing fonts when importing fonts afresh.
junaidpv’s picture

StatusFileSize
new3.01 KB

Sorry, just understood that removing already imported fonts is not good idea!
Here is the updated patch.

junaidpv’s picture

Version: 7.x-2.8 » 8.x-3.x-dev
StatusFileSize
new4.35 KB

Same as #10 but for 8.x-3.x

junaidpv’s picture

StatusFileSize
new4.4 KB

Corrected minor mistake in #11, it was creating blank font items when not receiving variant info. Enhanced, so font entry will get created only if a valid variant info is received.

Peter Buchanan’s picture

I'm getting the error "Typekit kit did not match current domain, ourglass8:8888" when I try to import fonts. I have other sites were the same typekit fonts were previously imported and they work OK.

Patch 12 wouldn't apply, terminal log says:

git apply -v typekit.patch
Checking patch modules/typekit_api/typekit_api.module...
error: while searching for:
$kits = typekit_api_get_kits($config->get('token'));
foreach ($kits as $kit_data) {
$kit = typekit_api_get_kit($kit_data->id, $config->get('token'));
if (typekit_api_kit_matches_domain($kit, $_SERVER['HTTP_HOST'])) {
foreach ($kit->families as $family) {
foreach ($family->variations as $variant_id) {
$variant = typekit_api_get_variant($family->id, $variant_id, $config->get('token'));
$metadata = [
'typekit_id' => $variant->id,
'variant' => $variant->font_variant,
'kit' => $kit->id,
];
$font_data = new stdClass();
$font_data->name = $variant->name;
$font_data->url = 'https://typekit.com/fonts/' . $family->slug . '#' . $variant_id;
$font_data->provider = 'typekit_api';
$font_data->css_family = "'" . implode("', '", $family->css_names) . "'";
$font_data->css_style = $variant->font_style;
$font_data->css_weight = $variant->font_weight;
$font_data->foundry_url = 'https://typekit.com/foundries/' . $variant->foundry->slug;
$font_data->metadata = $metadata;
$font = fontyourface_save_font($font_data);
$font->activate();
}
}
}
else {
Drupal::messenger()->addMessage(t('Typekit kit did not match current domain, @domain', ['@domain' => $_SERVER['HTTP_HOST']]));
}
}
Drupal::messenger()->addMessage(t('Imported Typekit kits: @kits', ['@kits' => print_r($kits, TRUE)]));
return $font_context;

error: patch failed: modules/typekit_api/typekit_api.module:106
error: modules/typekit_api/typekit_api.module: patch does not apply

I was in the fontyourface directory

Any thoughts?

junaidpv’s picture

@Peter patch is for dev branch. You might be using current release 8.x-3.2 of the module. Please try current dev release then you can apply the patch.

greenskunk’s picture

This works on the latest dev at 8.x-3.x-dev from 29 Mar 2023.

junaidpv’s picture

StatusFileSize
new4.79 KB

Re-rolled for the latest release 4.0.0