Giter Club home page Giter Club logo

Comments (4)

danrwalker avatar danrwalker commented on July 3, 2024 2

The issue comes about when the font weight parameter contains more than one weight. This means that the font files provided for that particular font-face are to be used for more than one weight, there was also some issues when detecting fonts that didn't have local() options in the SRC which Oswald did not.

I was working on a fix that ended up finding more issues and I ran out of time on the project. I have listed my changes below if any help to anyone. I believe this issues is now being fixed in #47 although I am not sure if that fix has the multiple font weight part in it as mentioned in previous comment.

Updated detection for both Local and Font Weight

var re = new RegExp([
	"\\s*font-family:\\s*'([^']+)';",
	"\\s*font-style:\\s*(\\w+);",
	"\\s*font-weight:\\s*([\\w\\s]+);",
	"\\s*src:\\s*(local\\('([^']+)'\\),\\s*local\\('([^']+)'\\),\\s*)?url\\(([^)]+)\\)[^;]*;",
	".*(?:unicode-range:([^;]+);)?",
].join(''), 'm');

Check see if local exists before outputting, added localBoth

function formatData(block, family, style, weight, localBoth, local1, local2, url, range) {
	var name = [family, style, weight].join('-') + '.' + ext;
	return {
		family: family,
		style: style,
		weight: weight,
		name: name.replace(/\s/g, '_'),
		url: url,
		local1: (!local1 || local1 === undefined) ? '' : local1,
		local2: (!local2 || local2 === undefined) ? '' : local2,
		range: range || 'U+0-10FFFF'
	};
}

Did a replace on the local part to correct an issue

function makeFontFace(request) {
	request.uri = path.posix.join(
		options.relativePaths ? path.posix.relative(options.cssDir, options.fontsDir) : options.fontsDir,
		request.name
	);
	request.name = path.posix.join(options.fontsDir, request.name);
	return template
		.replace(/\$(\w+)/g, function (m, name) {
			return request[name];
		}).replace(/(local\(\'\'\)\,\s)/g,'');
}

I didn't commit my work as it was never fully tested/finished, hopefully you might find it helpful.

from gulp-google-webfonts.

danrwalker avatar danrwalker commented on July 3, 2024

Upon looking into this further I think that the issues might be that the Oswald font comes back as a non standard font weight:

@font-face {
  font-family: 'Oswald';
  font-style: normal;
  font-weight: 200 700;
  font-display: swap;
  src: url(https://fonts.gstatic.com/s/oswald/v23/TK3iWkUHHAIjg752FD8Gl-1PK62t.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}

It would appear that the regX used (line 241 of index.js) to detect the font weight is not picking this up correctly.

Currently: "\\s*font-weight:\\s*(\\w+);",

Suggested: \\s*font-weight:\\s*([\\w\\s]+);

Also I have noticed that the are no local() parts in the returned font-face from google, would this also be a problem?

from gulp-google-webfonts.

samjameswatson avatar samjameswatson commented on July 3, 2024

I am also having this same issue but with the "Arvo" font - I tried to find a commonality between Arvo and Oswald but can't see any. Most fonts I tested worked fine but some returned ECONNREFUSED.

I also amended the regex as @danrwalker suggested but it didn't seem to make a difference for me - I believe Oswald is not returning font-weight 200 any longer.

from gulp-google-webfonts.

salim523 avatar salim523 commented on July 3, 2024

I am also having the same problem with Oswald. I try all the options but non of them are working. Below is the error code.

Error: unable to verify the first certificate
    at TLSSocket.onConnectSecure (_tls_wrap.js:1058:34)
    at TLSSocket.emit (events.js:198:13)
    at TLSSocket.EventEmitter.emit (domain.js:466:23)
    at TLSSocket._finishInit (_tls_wrap.js:636:8)

from gulp-google-webfonts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.