在Google Apps脚本中使用Google字体 [英] Using Google Fonts in Google Apps Scripts

查看:111
本文介绍了在Google Apps脚本中使用Google字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看过过有关 Caja 的文档,并过滤了Google字体的使用。关于这个问题,网络上最近没有任何行动。



有人知道在通过网络应用程序创建模板页面时使用Google字体的方法吗?

我已经尝试了它在Google API页面上提供的说明,但它始终默认为默认字体。 其他帖子似乎已被闲置一段时间,我想有人可能已经想出了一种方法来解决它。

解决方案

简单的解决方案,的文档(此处 here )。我做了三件事:


  1. 剥离了正文和标签。这感觉很奇怪,但它工作。
  2. 在我的code.gs文件中将我的沙盒模式更改为IFRAME

  3. 将以下代码添加到html模板在code.gs文件中调用

在code.gs中:

 函数doGet(){
var html = HtmlService
.createTemplateFromFile('index')
.evaluate()
.setTitle('Font测试')
.setSandboxMode(HtmlService.SandboxMode.IFRAME);
返回html;
}

在index.html文件中:

 <!DOCTYPE html> 

<?// HEAD?>
< base target =_ top>
< link rel =stylesheettype =text / csshref =https://fonts.googleapis.com/css?family=Tangerine>
< style>
body {
font-family:'Tangerine',serif;
font-size:48px;
}
< / style>

<?// BODY?>

< div>字体测试< / div>


I have seen the past documentation regarding Caja and filtering the use of Google Fonts. There hasn't been any recent action on the web regarding this issue.

Does anyone know of a way to use Google Fonts when creating a templated page via web apps?

I have tried the instructions it provides on the Google api pages but it always defaults to the default font. Other post seem to have been idle for a while and I thought someone might have figured out a way to pull it off.

解决方案

Simple solution, after I read through some of the documentation (here and here). I did 3 things:

  1. stripped out the body and head tags. That felt very weird but it worked.
  2. changed my sandbox mode to IFRAME in my code.gs file
  3. added the following code to the html template called in the code.gs file

In code.gs:

function doGet() {
  var html = HtmlService
  .createTemplateFromFile('index')
  .evaluate()
  .setTitle('Font Test')
  .setSandboxMode(HtmlService.SandboxMode.IFRAME);
  return html;
}

In index.html file:

<!DOCTYPE html>

  <?// HEAD ?>
    <base target="_top">
    <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Tangerine">
    <style>
      body {
        font-family: 'Tangerine', serif;
        font-size: 48px;
      }
    </style>

  <?// BODY ?>

    <div>Font Test</div>

这篇关于在Google Apps脚本中使用Google字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆