Stylesheet: Add StyleSheet

Collapse All

URL

http://api.fonts.com/rest/{format}/ProjectStyles/

{format}

xml or json

Method

POST

Required Header Parameters

  • authorizationHashed authorization key
  • appkeyYour application’s key

Required Query String Parameters

  • wfspidThe project id
  • wfsptokenproject token to be imported from

Optional Query String Parameters

  • wfspstartstarting record requested (zero-based)
  • wfsplimit# of records requested

Required Data Parameters

  • wfsselector_idsSelector ids to be imported seperated with a comma

Response variables

  • ProjectIDProject ID number
  • MessageIf the response is successful then the “message” parameter of the response will be “Success” and if there is some error or failure then the “message” parameter will be the error message.
  • Font: FontIDIdentifier of the font. Every font in the Fonts.com Web Fonts service has a unique FontID.
  • Font: FontNameDisplay name of the font.
  • Font: FontPreviewTextLongThe long text string used to show the appearance of the font.
  • Font: FontFoundryNameThe name of font designer or company.
  • Font: FontCSSNameThe font-family name of the font.
  • Font: FontLanguageThe language supported by the font.
  • Font: FontSizeThe size of the font file.
  • Font: CDNKeyThe authentication key for fetching the font file from the content distribution network (CDN).
  • Font: TTFThe font’s TrueType® font file ID. TrueType fonts can be used in all major browsers except for the Microsoft Internet Explorer® browser.
  • Font: EOTThe font’s Embedded OpenType Font file ID. EOT fonts are served exclusively to Internet Explorer browsers.
  • Font: WOFFThe font’s Web Open Font Format file ID. It is compatible with Firefox 3.6 and up. The WOFF file format is expected to eventually be compatible with all major browsers.
  • Font: SVGThe font’s Scalable Vector Graphics font file ID. This format is compatible with Apple iPhone, iPad and iPod touch devices.
  • Font: EnableSubsettingIndicates that a font should be dynamically subsetted in the website. Fonts with very large characters sets such as fonts support Chinese, Japanese and Korean writing systems can also have very large file sizes. Because it may take a long time to download a large file, fonts supporting these languages will be marked as EnableSubsetted fonts. The value will be either T for true or F for False.
  • TotalRecordsTotal number of records
  • PageStartstarting record requested (zero-based)
  • PageLimit# of records requested

Sample Code

PHP

<?php

require_once('Services_WFS.php');

$services = new Services_WFS;

$apiKey = '[Your API Key]';
$publicKey = '[Your Public Key]';
$privateKey = '[Your Private Key]';
$services->setCredentials($publicKey, $privateKey, $apiKey);

$my_project_name = '[project name]';
$projectKey = $wfs->getProjectKeyByName($my_project_name);
$services->setProjectKey($projectKey);

$result = $services->addStylesheet($stylesheetToken, $selectors);

var_dump($result);


?>      

C#

  private string AddStylesheet(string projectToken, IEnumerable<string> selectorsList, string projectId, int pageStart, int pageLimit)
  {

    const string method = "POST";
    string requestUri = "/rest/" + Format+ "/ProjectStyles/" + 
                                            "?wfspid=" + projectId + 
                                            "&wfsptoken=" + projectToken + 
                                            "&wfspstart=" + pageStart + 
                                            "&wfsplimit=" + pageLimit;

    string selectors = selectorsList.Aggregate<string, string>(null, (current, s) => string.Format("{0}, {1}", current, s));
    selectors = selectors.Substring(2);
      
    var data = "wfsselector_ids=" + selectors;

    //See common functions for GetResponse
    return GetResponse(method, requestUri, data);

  }
       

VB.NET

  Private Function AddStylesheet(ByVal projectToken As String, ByVal selectorsList As List(Of String), ByVal projectId As String, ByVal pageStart As Integer, ByVal pageLimit As Integer) As String

    Const method As String = "POST"
    Dim requestUri As String = "/rest/" & Format & "/ProjectStyles/" & _
                               "?wfspid=" & projectId & _
                               "&wfsptoken=" & projectToken & _
                               "&wfspstart=" & pageStart & _
                               "&wfsplimit=" & pageLimit

    Dim selectors As String
    selectors = selectorsList.Aggregate(selectors, Function(current, s) String.Format("{0}, {1}", current, s))
    selectors = Right(selectors, Len(selectors) - 2) 'remove the first char in string

    Dim data = "wfsselector_ids=" & selectors

    'See common functions for GetResponse
    Return GetResponse(method, requestUri, data)

  End Function

XML Response

<ProjectStyles>
  <ProjectID>7bff9927-7964-4f6f-a132-adcae35ad51f</ProjectID>
  <Message>Success</Message>
  <ProjectStyle>
    <SelectorID>3ff4c957-65fd-428d-a53b-3892da0b1960</SelectorID>
    <SelectorTag>h1</SelectorTag>
    <FontID>691782</FontID>
    <FontName>Albertusr Regular</FontName>
    <FontPreviewTextLong>Quick Brown Fox Jumped Over The Lazy Dog</FontPreviewTextLong>
    <FontFondryName>Monotype Imaging</FontFondryName>
    <FontCSSName>Albertus W01</FontCSSName>
    <FontLanguage></FontLanguage>
    <FontSize></FontSize>
    <CDNKey>d44f19a684109620e484147daf90e818082784eafd613082f04a2901e2fc90e07abf26e09077eeb422c4d34d256883d0</CDNKey>
    <TTF>9a98ab49-8706-4ba0-9de9-8de54c96bb4c</TTF>
    <EOT>39b01d2e-3d63-415e-aaae-408baea01666</EOT>
    <SVG>bda30cf7-8011-486d-81f5-d73a7d32e658</SVG>
    <WOFF>6605b509-e47b-45a6-8823-67b43b7e594c</WOFF>
    <EnableSubsetting>false</EnableSubsetting>
  </ProjectStyle>
  <TotalRecords>1</TotalRecords>
  <PageStart>0</PageStart>
  <PageLimit>10</PageLimit>
</ProjectStyles>

json Response

{
   "ProjectStyles":{
      "Message":"Success",
      "PageLimit":"10",
      "PageStart":"0",
      "ProjectID":"7bff9927-7964-4f6f-a132-adcae35ad51f",
      "ProjectStyle":{
         "CDNKey":"d44f19a684109620e484147daf90e818082784eafd613082f04a2901e2fc90e07abf26e09077eeb422c4d34d256883d0",
         "EnableSubsetting":"false",
         "EOT":"39b01d2e-3d63-415e-aaae-408baea01666",
         "FontCSSName":"Albertus W01",
         "FontFondryName":"Monotype Imaging",
         "FontID":"691782",
         "FontLanguage":null,
         "FontName":"Albertusr Regular",
         "FontPreviewTextLong":"Quick Brown Fox Jumped Over The Lazy Dog",
         "FontSize":null,
         "SelectorID":"3ff4c957-65fd-428d-a53b-3892da0b1960",
         "SelectorTag":"h1",
         "SVG":"bda30cf7-8011-486d-81f5-d73a7d32e658",
         "TTF":"9a98ab49-8706-4ba0-9de9-8de54c96bb4c",
         "WOFF":"6605b509-e47b-45a6-8823-67b43b7e594c"
      },
      "TotalRecords":"1"
   }
}